| Conditions | 1 |
| Paths | 1 |
| Total Lines | 110 |
| Lines | 110 |
| Ratio | 100 % |
| Changes | 3 | ||
| Bugs | 3 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /* eslint-enable describe it sinon */ |
||
| 10 | it('Should map width, order, and hidden only', () => { |
||
| 11 | |||
| 12 | const storageCoumns = [ |
||
| 13 | { |
||
| 14 | sortDirection: null, |
||
| 15 | className: 'additional-class', |
||
| 16 | width: '40%', |
||
| 17 | dataIndex: ['person', 'name'], |
||
| 18 | hidden: true, |
||
| 19 | name: 'Name', |
||
| 20 | expandable: true, |
||
| 21 | sortable: true, |
||
| 22 | id: 'TmFtZWdyaWQtY29sdW1u' |
||
| 23 | }, |
||
| 24 | { |
||
| 25 | name: 'Phone Number', |
||
| 26 | dataIndex: 'Phone Number', |
||
| 27 | sortable: true, |
||
| 28 | className: 'additional-class', |
||
| 29 | id: 'UGhvbmUgTnVtYmVyZ3JpZC1jb2x1bW4=', |
||
| 30 | sortDirection: null |
||
| 31 | }, |
||
| 32 | { |
||
| 33 | name: 'Email', |
||
| 34 | dataIndex: 'Email', |
||
| 35 | sortable: true, |
||
| 36 | className: 'additional-class', |
||
| 37 | defaultSortDirection: 'descend', |
||
| 38 | id: 'RW1haWxncmlkLWNvbHVtbg==', |
||
| 39 | sortDirection: null |
||
| 40 | }, |
||
| 41 | { |
||
| 42 | name: 'Address', |
||
| 43 | dataIndex: 'Address', |
||
| 44 | sortable: true, |
||
| 45 | className: 'additional-class', |
||
| 46 | id: 'QWRkcmVzc2dyaWQtY29sdW1u', |
||
| 47 | sortDirection: 'DESC' |
||
| 48 | } |
||
| 49 | ]; |
||
| 50 | |||
| 51 | const propColumns = [ |
||
| 52 | { |
||
| 53 | name: 'Phone Number', |
||
| 54 | dataIndex: 'Phone Number', |
||
| 55 | sortable: true, |
||
| 56 | className: 'additional-class' |
||
| 57 | }, |
||
| 58 | { |
||
| 59 | className: 'additional-class', |
||
| 60 | width: '45%', |
||
| 61 | dataIndex: ['person', 'name'], |
||
| 62 | hidden: false, |
||
| 63 | name: 'Name', |
||
| 64 | expandable: true, |
||
| 65 | sortable: true, |
||
| 66 | renderer: () => {} |
||
| 67 | }, |
||
| 68 | { |
||
| 69 | name: 'Email', |
||
| 70 | dataIndex: 'Email', |
||
| 71 | sortable: true, |
||
| 72 | className: 'additional-class', |
||
| 73 | defaultSortDirection: 'descend' |
||
| 74 | }, |
||
| 75 | { |
||
| 76 | name: 'Address', |
||
| 77 | dataIndex: 'Address', |
||
| 78 | sortable: true, |
||
| 79 | className: 'additional-class' |
||
| 80 | } |
||
| 81 | ]; |
||
| 82 | |||
| 83 | const result = [ |
||
| 84 | { |
||
| 85 | className: 'additional-class', |
||
| 86 | width: '40%', |
||
| 87 | dataIndex: ['person', 'name'], |
||
| 88 | hidden: true, |
||
| 89 | name: 'Name', |
||
| 90 | expandable: true, |
||
| 91 | sortable: true, |
||
| 92 | renderer: () => {} |
||
| 93 | }, |
||
| 94 | { |
||
| 95 | name: 'Phone Number', |
||
| 96 | dataIndex: 'Phone Number', |
||
| 97 | sortable: true, |
||
| 98 | className: 'additional-class' |
||
| 99 | }, |
||
| 100 | { |
||
| 101 | name: 'Email', |
||
| 102 | dataIndex: 'Email', |
||
| 103 | sortable: true, |
||
| 104 | className: 'additional-class', |
||
| 105 | defaultSortDirection: 'descend' |
||
| 106 | }, |
||
| 107 | { |
||
| 108 | name: 'Address', |
||
| 109 | dataIndex: 'Address', |
||
| 110 | sortable: true, |
||
| 111 | className: 'additional-class' |
||
| 112 | } |
||
| 113 | ]; |
||
| 114 | |||
| 115 | expect( |
||
| 116 | getColumnsFromStorage(storageCoumns, propColumns) |
||
| 117 | ).toEqual(result); |
||
| 118 | |||
| 119 | }); |
||
| 120 | |||
| 376 |